home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / misc / emu / Apex-src.lha / INSTALL.XPL < prev    next >
Text File  |  2001-09-30  |  4KB  |  179 lines

  1. \INSTALL.XPL    APR-10-87
  2. \Resident Code Loader
  3. \Written by Loren Blaney for DFM Engineering
  4.  
  5. \REVISION HISTORY:
  6. \SEP-26-86, ORIGINAL
  7. \FEB-13-87, Changed MEMTOP to $80000 for Amiga, added display of MEMTOP,
  8. \ and show when bytes are outside legal load range.
  9. \APR-10-87, Changed string conventions.
  10. \
  11. \NOTES:
  12. \This program is used to load code into the resident area of Apex. It
  13. \ writes directly to the boot disk. The disk must be rebooted to
  14. \ actually load the modified RESCOD into memory. It is most often used
  15. \ to install device handlers, but it will install anything within the
  16. \ upper and lower portions of RESCOD memory (this includes INT).
  17.  
  18. code
  19. ABS=0,        RAN=1,        REM=2,        RESERVE=3,
  20. SWAP=4,        EXTEND=5,    RESTART=6,    CHIN=7,
  21. CHOUT=8,    CRLF=9,        INTIN=10,    INTOUT=11,
  22. TEXT=12,    OPENI=13,    OPENO=14,    CLOSE=15,
  23. SCAN=24,    FWRITE=30,    FREAD=31,    HEXOUT=27;
  24.  
  25. def    INTSIZE=4;    \Number of bytes in an integer (2 or 4)
  26. def    RESSIZE=80;    \Number of blocks in RESCOD.SYS.  (WARNING: If this
  27.             \ value is changed, must also change error message)
  28. def    TV=0, KB=0;
  29. def    BEL=$07, EOF=$1A;
  30.  
  31. int    MEMTOP,        \Highest memory location +1
  32.     UNIT,        \Unit number containing RESCOD.SYS
  33.     PC,        \The current relative load address
  34.     CHAR,        \Character read in by GETCH from disk
  35.     BLOCK;        \Holds start and end blocks of SCANed file
  36.  
  37. addr    BUFFER;        \Holds the loaded file which is written to disk
  38.  
  39.  
  40.  
  41. proc    ERROR(STR);    \Display error message and exit
  42. addr    STR;
  43. begin
  44. TEXT(TV,"
  45. OH OH - ");
  46. CHOUT(TV,BEL);
  47. TEXT(TV,STR);
  48. CRLF(TV);
  49. exit;
  50. end;    \ERROR
  51.  
  52.  
  53.  
  54. func    SWAPWD(I);    \Swap words in a 32-bit integer
  55. int    I;
  56. addr    A;
  57. int    T;
  58. begin
  59. A:= addr I;
  60. T:=A(0); A(0):=A(2); A(2):=T;
  61. T:=A(1); A(1):=A(3); A(3):=T;
  62. return I;
  63. end;    \SWAPWD
  64.  
  65.  
  66.  
  67. proc    GETCH;        \Get CHAR from disk, filter out CR's, etc.
  68. begin
  69. loop    begin
  70.     CHAR:= CHIN(3);
  71.     if CHAR>$20 then quit;
  72.     if CHAR=EOF then quit;
  73.     end;
  74. end;    \GETCH
  75.  
  76.  
  77.  
  78. func    HEXNYBBLE;    \Return the value of the hex nybble
  79. int    HEX;
  80. begin
  81. case of
  82.   CHAR>=^0 & CHAR<=^9: HEX:= CHAR -^0;
  83.   CHAR>=^A & CHAR<=^F: HEX:= CHAR -$37
  84. other ERROR("HEX CHARACTER EXPECTED");
  85. GETCH;                    \Look ahead one character
  86. return HEX;
  87. end;    \HEXNYBBLE
  88.  
  89.  
  90.  
  91. func    HEXBYTE;    \Read in 2 chars and return the value of the hex byte
  92. begin
  93. return HEXNYBBLE <<4 + HEXNYBBLE;
  94. end;    \HEXBYTE
  95.  
  96.  
  97.  
  98. func    HEXWORD;    \Read in 4 chars and return the value of the hex word
  99. begin
  100. return HEXBYTE <<8 + HEXBYTE;
  101. end;    \HEXWORD
  102.  
  103.  
  104.  
  105. func    HEXLONG;    \Read in 8 chars and return the value of the hex long
  106. begin
  107. return SWAPWD(HEXWORD) +HEXWORD;
  108. end;    \HEXLONG
  109.  
  110.  
  111.  
  112. proc    STOBYTE(BYTE);    \Store a byte at the current PC
  113. int    BYTE;
  114. begin
  115. if PC>=$0000 & PC<$1000 then        \Only store bytes within legal range
  116.     BUFFER(PC):= BYTE;
  117. if PC>=MEMTOP-$4000 & PC<MEMTOP then
  118.     BUFFER(PC -MEMTOP +$5000):= BYTE;
  119.  
  120. case of
  121.   PC>=MEMTOP-$4000 & PC<MEMTOP:
  122.     BUFFER(PC -MEMTOP +$5000):= BYTE;
  123.   PC>=$0000 & PC<$1000:            \Only store bytes within legal range
  124.     BUFFER(PC):= BYTE
  125. other CHOUT(TV,^-);            \Indicate something is being chopped
  126.  
  127. PC:= PC +1;
  128. end;    \STOBYTE
  129.  
  130.  
  131.  
  132. begin    \MAIN
  133. BUFFER:= RESERVE(RESSIZE *$100);
  134. BLOCK:= RESERVE(2 *INTSIZE);
  135. MEMTOP:= $80000;
  136.  
  137. TEXT(TV,"-- RESIDENT CODE INSTALLER, V1.0x3 --
  138. MEMTOP: $"); HEXOUT(TV, MEMTOP);
  139. TEXT(TV,"
  140. WHICH UNIT (0-7)? ");
  141.  
  142. UNIT:= INTIN(KB);
  143. SCAN(UNIT, BLOCK, "RESCOD  SYS");
  144. if BLOCK(0)#17 then
  145.     ERROR("RESCOD.SYS MUST BE THE FIRST FILE ON THE DISK");
  146. if BLOCK(1) - BLOCK(0) + 1 # RESSIZE then
  147.     ERROR("RESCOD.SYS MUST BE 80 BLOCKS LONG");
  148.  
  149. TEXT(TV,"LOADING... ");
  150.  
  151. FREAD(UNIT, 17, BUFFER, RESSIZE);
  152.  
  153. \Now load the code to be installed:
  154. PC:= 0;                    \Default PC
  155. OPENI(3);
  156. GETCH;
  157. loop    begin
  158.     case CHAR of
  159.       ^@:    [GETCH; PC:= HEXLONG];
  160.       EOF:    quit
  161.     other STOBYTE(HEXBYTE);
  162.     end;
  163.  
  164. TEXT(TV,"
  165. MODIFYING ");
  166. INTOUT(TV,UNIT);
  167. TEXT(TV,":RESCOD.SYS - ARE YOU SURE (N/Y)? ");
  168.  
  169. OPENI(KB);
  170. if (CHIN(KB) ! $20) = ^y then
  171.     begin
  172.     FWRITE(UNIT, 17, BUFFER, RESSIZE);
  173.     TEXT(TV,"THE DEED IS DONE");
  174.     end
  175. else    TEXT(TV,"OK, IT'S NOT MODIFIED");
  176. CRLF(TV);
  177. end;    \MAIN
  178. IT, 17, BUFFER, RESSIZE);
  179.     TEXT(TV,"THE DEED IS DONE")